package fr.umlv.m2.jee.spij.persistence.education.dao;

import fr.umlv.m2.jee.spij.framework.dao.hibernate.AbstractHibernateDAO;
import fr.umlv.m2.jee.spij.persistence.education.IKeyWordDAO;
import fr.umlv.m2.jee.spij.persistence.education.KeyWord;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

/**
 *
 */
@Repository("hibernateKeyWordDAO")
public class HibernateKeyWordDAO extends AbstractHibernateDAO<Long, KeyWord>
        implements IKeyWordDAO {

    @Override
    public final KeyWord findByWording(final String wording) {

        Session session = getHibernateSession();
        Criteria criteria = session.createCriteria(KeyWord.class);
        criteria.add(Restrictions.like("wording", wording));
        return (KeyWord) criteria.uniqueResult();
    }

}
